package com.his.controller;


import com.his.entity.ResponseResult;
import com.his.entity.Staff;
import com.his.service.IStaffService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 员工表 前端控制器
 * </p>
 *
 * @author Demoon Liu
 * @since 2022-02-20
 */
@Tag(name = "StaffController--员工管理接口")
@RestController
@RequestMapping("/staff")
public class StaffController {

    @Resource
    public IStaffService staffService;

    @Operation(summary = "增加员工",description = "输入：{\n" +
            "  \"username\": \"string\",\n" +
            "  \"password\": \"string\",\n" +
            "  \"status\": 1,\n" +
            "  \"gender\": 0,\n" +
            "  \"skdflag\": 0,\n" +
            "  \"title\": \"string\",\n" +
            "  \"name\": \"string\",\n" +
            "  \"deptid\": 0,\n" +
            "  \"registrationrankid\": 0,\n" +
            "}。 返回：一个员工Staff信息")
    @PostMapping("/add")
    public ResponseResult addStaff(@RequestBody Staff staff){
        return staffService.addStaff(staff);
    }

    @Operation(summary = "删除员工",description ="输入：员工id。 返回：无")
    @PostMapping("/delete")
    public ResponseResult deleteStaff(@RequestBody long id){
        return staffService.deleteStaff(id);
    }

    @Operation(summary = "修改员工",description ="输入：同添加。 返回：一个员工Staff信息")
    @PostMapping("/update")
    public ResponseResult updateStaff(@RequestBody Staff staff){
        return staffService.updateStaff(staff);
    }

    @Operation(summary = "通过用户名查询",description ="输入：staff（用户名）。 返回：一个员工Staff信息")
    @PostMapping("/select")
    public ResponseResult selectStaffByUsername(@RequestBody Staff staff){
        return staffService.selectStaffByUsername(staff);
    }

    @Operation(summary = "查询所有员工",description ="输入：无。 返回：多个员工Staff信息")
    @PostMapping("/selectall")
    public ResponseResult selectAllStaff(){
        return staffService.selectAllStaff();
    }

    @Operation(summary = "模糊查询员工",description ="输入：String类型的（username或者title）。 返回：多个员工Staff信息")
    @PostMapping("/selectlike")
    public ResponseResult selectLike(@RequestBody String str){ return staffService.selectLike(str); }


}
